script_enemy_main{

let effect1=0;
let object1=[];
let count1=[];
let angle1=[];
let fanangle=0;

let angle=rand(0,360);

let character="Setsuko";
let cutin=character;
let dispelled=0;
let spellcards=4;
let spellcardnumber=2;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=-60;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshot1=("script\SoundEffects\shots6.wav");
let SEshot2=("script\SoundEffects\shotm4.wav");
let SEfan=("script\SoundEffects\fan1.wav");
let GRfan=("\script\Images\OtherEffects\Fan1.png");

let BG1=("\script\Images\BackgroundLayers\setsuko1.png");
let BG2=("\script\Images\BackgroundLayers\setsuko2.png");
let GRboss=("\script\Images\CharacterSprites\Setsuko.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsSetsuko1.txt");

	LoadGraphic("\script\Images\CharacterSprites\Setsuko.png");
	LoadGraphic("\script\Images\BackgroundLayers\setsuko1.png");
	LoadGraphic("\script\Images\BackgroundLayers\setsuko2.png");
	LoadGraphic("\script\Images\OtherEffects\Fan1.png");

	LoadSE("script\SoundEffects\shots6.wav");
	LoadSE("script\SoundEffects\shotm4.wav");
	LoadSE("script\SoundEffects\fan1.wav");

	SetScore(100000);
	SetLife(175);
	SetTimer(30);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,miny+140,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(64,64,64,64);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=4; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Morality [Unwritten Code Of Ethics] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);

if((time+90)%180==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+120,miny+160),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+120,miny+160),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+120,miny+160),1.5);
	}
}


if(frame>60 && frame<180){
let speed=0;
	loop(5){
	CreateShot01(GetX+5,GetY-15,3.5-speed,angle,3,0);
	speed+=0.6;
	SetShotColor(255-(speed*40),255-(speed*40),255-(speed*40));
	}
	if(time%4==0){
	PlaySE(SEshot1);
	}
SetShotColor(255,255,255);
angle+=rand(8,13);
usespell=2;
}

if(time%90==0 && time>=180){
	SetShotDirectionType(PLAYER);
	loop(2){ CreateShot01(GetX-100,GetY,2,0,13,15); }
	loop(2){ CreateShot01(GetX+100,GetY,2,0,13,15); }
	SetShotDirectionType(ABSOLUTE);
	PlaySE(SEshot2);
}

if(frame==180){ frame=0; }



if(time==60){
let picture=0;
let i=0;
	loop(16){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,GetX,GetY);
	ObjEffect_SetScale(effect1,1,1); ObjEffect_SetAngle(effect1,0,0,-90);
	ObjEffect_SetLayer(effect1,1); ObjEffect_SetTexture(effect1,GRfan); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-25,-175); ObjEffect_SetVertexUV(effect1,0,0+picture,0);
	ObjEffect_SetVertexXY(effect1,1,25,-175); ObjEffect_SetVertexUV(effect1,2,0+picture,350);
	ObjEffect_SetVertexXY(effect1,2,-25,175); ObjEffect_SetVertexUV(effect1,1,50+picture,0);
	ObjEffect_SetVertexXY(effect1,3,25,175); ObjEffect_SetVertexUV(effect1,3,50+picture,350);
	ObjEffect_SetVertexColor(effect1,0,255,255,255,255); ObjEffect_SetVertexColor(effect1,1,255,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,125,255,255,255); ObjEffect_SetVertexColor(effect1,3,125,255,255,255);
	object1=object1~[effect1];
	count1=count1~[effect1];
	count1[length(object1)-1]=i*12;
	angle1=angle1~[effect1];
	angle1[length(object1)-1]=0;
	if((i+1)%2==0){ picture=0; }
	if((i+0)%2==0){ picture=50; }
	i++;
	}
}

if(time>=60){
let i=0;
	loop(16){
	Obj_SetPosition(object1[i],GetX,GetY);
	ObjEffect_SetAngle(object1[i],0,0,-90+angle1[i]+fanangle);
	if(angle1[i]<count1[i]){ angle1[i]=angle1[i]+4; fanangle+=1; }
	if(angle1[i]==count1[i] && time>=80 && time%3==0){ PlaySE(SEfan); angle1[i]=count1[i]+0.01; }
	i++;
	}
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<255){bgfade+=5;}

	SetGraphicRect(0,0,300,400);
	SetGraphicScale(1.3,1.3);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(180,180,180);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,250,320);
	SetGraphicScale(1.25,1.25);
	SetTexture(BG2);
	DrawGraphic(cx,cy);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
//	SetCommonData("Conversation",1);
	SetCommonData("ItemSpawn",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}